import axios from '../utils/request'      //引入封装好的axios
import base from './base'                 //引入接口列表

const api = {
    /**
     * 登录功能
     */
    login(params){
        return axios.post(base.baseURI+base.login,params)
    },
    get_menu(params){
        return axios.get(base.baseURI+base.get_menu,params)
    },
    get_menu_list(params){
        return axios.get(base.baseURI+base.get_menu_list, params)
    },
    get_users_list(params){
        return axios.get(base.baseURI+base.get_users, params)
    },
    add_user(params){
        return axios.post(base.baseURI+base.get_users, params)
    },
    edit_user(id,params){
        return axios.put(base.baseURI+base.edit_user+id+'/', params)
    },
    delete_user(id){
        return axios.delete(base.baseURI+base.delete_user+id+'/')
    },
    reset_user_password(id){
        return axios.get(base.baseURI+base.reset_user_password+id+'/')
    },
    get_roles(params){
        return axios.get(base.baseURI+base.get_roles,params)
    },
    del_role_menu(rid,mid){
        return axios.get(base.baseURI+base.del_role_menu+rid+'/'+mid+'/')
    },
    set_menu(rid,params){
        return axios.post(base.baseURI+base.set_menu+rid+'/',params)
    },
    get_category(level){
        return axios.get(base.baseURI+base.get_category+'?level='+level)
    },
    add_category(params){
        return axios.post(base.baseURI+base.get_category,params)
    },
    get_attr_by_category(cid,_type){
        return axios.get(base.baseURI+base.get_attr_by_category+'?cid='+cid+'&_type='+_type)
    },
    add_attr(params){
        return axios.post(base.baseURI+base.add_attr,params)
    },
    update_attr_value(id,params){
        return axios.put(base.baseURI+base.add_attr_value+id+'/',params)
    },
    get_product_list(name){
        if(name){
            return axios.get(base.baseURI+base.get_product_list+'?name='+name)
        }else{
            return axios.get(base.baseURI+base.get_product_list)
        }

    },
    delete_product(id){
        return axios.delete(base.baseURI+base.delete_product+id+'/')
    },
    add_product(params){
        return axios.post(base.baseURI+base.add_product,params)
    },
    get_orders(params){
        return axios.get(base.baseURI+base.get_orders,params)
    },
    get_express(id){
        return axios.get(base.baseURI+base.get_express+id+'/')
    },
    get_cate_group(){
        return axios.get(base.baseURI+base.get_cate_group)
    }

}

export default api